package com.springboot.demo.config.mongo;

import com.springboot.demo.config.DemoConfigService;
import com.springboot.mongo.config.MongoConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mongo配置
 *
 * @author supu
 * @date 2019-08-26 14:52
 **/
@Configuration
public class MongoConfiguration {
    @Autowired
    private DemoConfigService demoConfigService;

    @Bean
    public MongoConfigurer mongoConfigurer() {
        return new MongoConfigurer(demoConfigService.getValueByKey(DemoConfigService.MONGO_USER_NAME),
                demoConfigService.getValueByKey(DemoConfigService.MONGO_PASSWORD),
                demoConfigService.getValueByKey(DemoConfigService.MONGO_HOST_LIST),
                demoConfigService.getValueByKey(DemoConfigService.MONGO_DATABASE_NAME));
    }
}
